# -*- coding: utf-8 -*-
import numpy as np
import torch
import matplotlib.pyplot as plt
import matplotlib
# setting the matplotlib backend.
matplotlib.use("Agg")
import sys
sys.path.append("/gpfs/scratch/chgwang/XI/Scripts/MLModel")
import ParallelNet # type: ignore
# import FedSeq_normal # type: ignore


# 以200为步长进行移步计算TPR, FPR, F-Score.
# the output is list of probability.
def pltout(model, inputArr:np.array):
    interval = 200
    inputLen = inputArr.shape[1]
    outlist = []
    model.eval()
    for i in range(interval, inputLen-interval):
        # 倒置拼接法
        per_input = inputLen[:,i-200:i]
        with torch.no_grad():
            per_out = model(per_input)
        outlist.append(per_out)
    return(outlist)


if __name__ == "__main__":
    # loading
    model_path = ""  # PathStr
    model = ParallelNet.ParallelNet(output_size=6)
    model_dict = model.state_dict()
    trained_dict = torch.load(model_path)
    trained_dict = {k: v for k, 
    v in trained_dict.items() if k in model_dict}
    model_dict.update(trained_dict)
    model.load_state_dict(model_dict)

    
